
import java.util.HashMap;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pson
 */
public class Player {

    /**
     * Player name
     */
    private String name;
    /**
     * Amount of each resource the player has
     */
    private HashMap<Resource, Integer> resources;

    public Player(String name) {
        this.name = name;
    }
    
    /**
     * Gets the number of units of the given resource the player currently possesses
     * @param r
     * @return 
     */
    public int getResourceNum(Resource r) {
        if (!resources.containsKey(r)) {
            resources.put(r, 0);
        }
        return resources.get(r);
    }
    
    /**
     * Adds [num] units of the given resource [r] to the player's pool
     * @param r
     * @param num 
     */
    public void addResource(Resource r, int num) {
        int n = getResourceNum(r) + num;
        resources.put(r, n);
    }
}
